package com.base.sms.config;

import com.base.sms.model.enums.RepositoryTypeEnum;
import com.base.sms.model.enums.SMSHandlerEnum;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.Serializable;

@Component
@ConfigurationProperties(prefix = "sms.verification-code")
public class SMSConfig implements Serializable {

    /**
     * 手机号码正则规则
     */
    private String regx;

    /**
     * 验证码过期时间,小于等于0表示不过期,单位秒
     */
    private Long expirationTime;

    /**
     * 重新发送验证码间隔时间,小于等于0表示不启用,单位秒
     */
    private Long retryIntervalTime;

    /**
     * 验证码长度
     */
    private int codeLength = 6;

    /**
     * 是否使用识别码
     */
    private boolean useIdentificationCode = false;

    /**
     * 识别码长度
     */
    private int identificationCodeLength = 3;

    /**
     * 验证成功是否删除验证码
     */
    private boolean deleteByVerifySucceed = true;

    /**
     * 验证失败是否删除验证码
     */
    private boolean deleteByVerifyFail = true;

    /**
     * 模板中是否包含过期时间
     */
    private boolean templateHasExpirationTime = true;

    private String repository = RepositoryTypeEnum.MEMORY.type();

    private String smsHandlerType = SMSHandlerEnum.AIXUN.type();


    public String getRegx() {
        return this.regx;
    }

    public Long getExpirationTime() {
        return this.expirationTime;
    }

    public Long getRetryIntervalTime() {
        return this.retryIntervalTime;
    }

    public int getCodeLength() {
        return this.codeLength;
    }

    public boolean isUseIdentificationCode() {
        return this.useIdentificationCode;
    }

    public int getIdentificationCodeLength() {
        return this.identificationCodeLength;
    }

    public boolean isDeleteByVerifySucceed() {
        return this.deleteByVerifySucceed;
    }

    public boolean isDeleteByVerifyFail() {
        return this.deleteByVerifyFail;
    }

    public boolean isTemplateHasExpirationTime() {
        return this.templateHasExpirationTime;
    }

    public void setRegx(String regx) {
        this.regx = regx;
    }

    public void setExpirationTime(Long expirationTime) {
        this.expirationTime = expirationTime;
    }

    public void setRetryIntervalTime(Long retryIntervalTime) {
        this.retryIntervalTime = retryIntervalTime;
    }

    public void setCodeLength(int codeLength) {
        this.codeLength = codeLength;
    }

    public void setUseIdentificationCode(boolean useIdentificationCode) {
        this.useIdentificationCode = useIdentificationCode;
    }

    public void setIdentificationCodeLength(int identificationCodeLength) {
        this.identificationCodeLength = identificationCodeLength;
    }

    public void setDeleteByVerifySucceed(boolean deleteByVerifySucceed) {
        this.deleteByVerifySucceed = deleteByVerifySucceed;
    }

    public void setDeleteByVerifyFail(boolean deleteByVerifyFail) {
        this.deleteByVerifyFail = deleteByVerifyFail;
    }

    public void setTemplateHasExpirationTime(boolean templateHasExpirationTime) {
        this.templateHasExpirationTime = templateHasExpirationTime;
    }

    public String getRepository() {
        return repository;
    }

    public void setRepository(String repository) {
        this.repository = repository;
    }

    public String getSmsHandlerType() {
        return smsHandlerType;
    }

    public void setSmsHandlerType(String smsHandlerType) {
        this.smsHandlerType = smsHandlerType;
    }
}